package com.edu.aspects;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspects {
    @Pointcut("execution(* com.edu.service..*.select*(..))")
    public void pt1(){}

    @Around("pt1()")
    public Object around(ProceedingJoinPoint jt){
        long start = System.currentTimeMillis();
        Object o = null;
        try {
            o = jt.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println("方法:"+jt.getTarget().getClass().getName()+",耗时:"+(end-start));
        return o;
    }
}
